package cool.taomu.toolkit.httpclient

import com.google.inject.Provider
import java.lang.reflect.Proxy

class ProxyProvider implements Provider<Object> {
    ClassLoader loader
    Class<?> zlass

    new(ClassLoader loader, Class<?> zlass) {
        this.loader = loader
        this.zlass = zlass
    }

    override get() {
        Proxy.newProxyInstance(loader, #[zlass], [ proxy, method, args |
            ApacheHttpInvoker.invoke(zlass, method, args)
        ])
    } 
}